package org.example.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class PerformanceAspect {
    @Around("execution(* org.example.service.UserService.*(..))")
    public Object aroundAdvice(ProceedingJoinPoint pjp) throws Throwable {
        long starTime = System.currentTimeMillis();
        Object result = pjp.proceed();
        long endTime = System.currentTimeMillis();
        System.out.println("Method" + pjp.getSignature().getName() + "took" + (endTime -starTime) + "ms");
        return result;
    }
}
